package ru.scan2d.main.impl;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.MenuBar;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

import ru.scan2d.main.MainWindowPresenter;
import ru.scan2d.main.MainWindowPresenter.Listener;

public class MainWindowImpl extends JFrame{
	
	private MainWindowPresenter presenter;
	private Listener listener;
	private JPanel component;
	public MainWindowImpl(JMenuBar menu){
		this.setTitle("Scan2D");
		this.setJMenuBar(menu);
		this.setSize(Toolkit.getDefaultToolkit().getScreenSize());
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		this.setLayout(new java.awt.BorderLayout());
		this.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
		component = new JPanel();
		this.add(component, BorderLayout.CENTER);
		this.repaint();
		this.show();
	}
	
	public void setPresenter(MainWindowPresenter presenter) {
		this.presenter = presenter;
	}
	
	public void setListener(MainWindowPresenter.Listener listener) {
		this.listener = listener;
	}

	public void updateCenter(JPanel panel) {
		
		this.remove(component);
		component = panel;
		this.add(component, BorderLayout.CENTER);
		repaint();
		show();
	}

}
